package com.hxalex.simulationhandle.ui.home;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;

import com.hxalex.simulationhandle.R;
import com.hxalex.simulationhandle.accessbilityService.manger.WifiManger;
import com.hxalex.simulationhandle.databinding.ActivityActivationBinding;
import com.hxalex.simulationhandle.ui.base.BaseActivity;

import java.util.Timer;
import java.util.TimerTask;

public class ActivationActivity extends BaseActivity {
private ActivityActivationBinding mBinding;
public static final String TO="to";
public static String  TO_WIFI="TO_WIFI";
public static String  TO_BROWSER="TO_BROWSER";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setStatusBarResource(R.color.transparent);
        super.onCreate(savedInstanceState);
        mBinding= DataBindingUtil.setContentView(this,R.layout.activity_activation);
        String to = getIntent().getStringExtra(TO);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getWindow().getDecorView().setBackgroundColor(Color.TRANSPARENT);
        
        Timer timer=new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                finish();
                String pn=to.equals(TO_WIFI)?getResources().getString(R.string.wifi_app_package_name):getResources().getString(R.string.browser_app_package_name);
                if((pn.equals(getResources().getString(R.string.wifi_app_package_name)) && !WifiManger.isOpenWifiAppActiviy) || pn.equals(getResources().getString(R.string.browser_app_package_name)))
                {
                    WifiManger.isOpenWifiAppActiviy=true;
                    Intent i =getPackageManager().getLaunchIntentForPackage(pn);
                    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(i);
                }
                
             
            }
        },1000);
        
    }
}
